import axios from "axios";
import config from "../appData"
axios.defaults.baseURL = `${config.host}/`;
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';


function post_data(Param){
 var  param =  tool(Param)
    var data = param.data||{},
    url = param.url||'/test',
    success = param.success||null,
    fail = param.fail||null;

    axios.post(url, data)
      .then(function (response) {
        typeof success == 'function' && success(response.data)
      })
      .catch(function (error) {
        typeof fail == 'function' && fail(error)
      });
}
function tool(Param){
    return Param
}
export default {
    post_data
}